package day03;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**
 * 输入某人生日，格式为"yyyy-MM-dd"，输出到现在为止经过了多少周。
 * @author Bonnie
 *
 */
public class Test03 {
    public static void main(String[] args) throws ParseException {
        Scanner input=new Scanner(System.in);
        System.out.println("请输入生日：");
        String birthday=input.next();
        SimpleDateFormat dt=new SimpleDateFormat("yyyy-MM-dd");
        String rule="[\\d]{4}-[\\d]{1,2}-[\\d]{1,2}";
        if (birthday.matches(rule)){
            Date bir=dt.parse(birthday);
            Date now=new Date();
            long time=now.getTime()-bir.getTime();
            long day=time/1000/60/60/24;
            long week=day/7;
            System.out.println("距今"+week+"周");
        }
        else {
            System.out.println("时间格式输入不正确！");
        }

    }

}
